package com.orangelife.mobile.propertyOld.biz;

import com.curry.android.http.OrangeErrorHandler;
import com.curry.android.http.VolleyHttpUtil;
import com.curry.android.util.JSONHelper;
import com.orangelife.mobile.constants.PropertyURL;

import org.json.JSONObject;

import java.util.HashMap;
import java.util.Map;

/**
 * 旧的缴费API
 * <p/>
 * Created by Administrator on 2015/12/3.
 */
public class PropertyHttpOldBiz {

    public static void getLastOrder(String commID, String apartmentID, VolleyHttpUtil.ResponseCallBack callback) {
        HashMap<String, String> urlMap = new HashMap<>();
        urlMap.put("commID", commID);
        urlMap.put("apartmentID", apartmentID);
        urlMap.put("type", "1");
        VolleyHttpUtil.getInstance().getWithCallback(PropertyURL.FEE_DETAIL, urlMap, callback);
    }

    /**
     * 我的物业缴费信息回调(新)
     *
     * @param response
     * @return
     */
    public static Map<String, Object> handleLastOrder(JSONObject response) {
        Map<String, Object> list = null;
        if (OrangeErrorHandler.getInstance().isSuccess(response)) {
            HashMap<String, Object> map = (HashMap<String, Object>) JSONHelper
                    .jsonToMap(String.valueOf(response));
            list = map;
        }
        return list;
    }

    public static void getPropertyBillDetail(String orderID, VolleyHttpUtil.ResponseCallBack callback) {
        HashMap<String, String> urlMap = new HashMap<>();
        urlMap.put("{orderID}", orderID);
        VolleyHttpUtil.getInstance().getWithCallback(PropertyURL.URL_PROPERTY_BILL_DETAIL, urlMap, callback);
    }

    /**
     * 我的物业缴费账单明细回调
     *
     * @param response
     * @return
     */
    public static Map<String, Object> handlePropertyBillDetail(JSONObject response) {
        Map<String, Object> list = null;
        if (OrangeErrorHandler.getInstance().isSuccess(response)) {
            HashMap<String, Object> map = (HashMap<String, Object>) JSONHelper
                    .jsonToMap(String.valueOf(response));
            if (map != null) {
                list = (HashMap<String, Object>) map
                        .get("entity");
            }
        }
        return list;
    }
}
